/**
 * Copyright (c) 2013 Mark Tielemans
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * DISCLAIMER
 * This software is provided "as is" and any expressed or implied warranties, including, but not limited to, the implied warranties of 
 * merchantability and fitness for a particular purpose are disclaimed. In no event shall the regents or contributors be liable for any 
 * direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute 
 * goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in 
 * contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if 
 * advised of the possibility of such damage.
 */
package nl.marktielemans.easydb;

import java.util.ArrayList;
import java.util.List;

import nl.marktielemans.easydb.connection.DatabaseConnector;
import nl.marktielemans.easydb.connection.MySQLConnector;
import nl.marktielemans.easydb.generator.MySQLQueryGenerator;
import nl.marktielemans.easydb.generator.QueryGenerator;

/**
 * Represents a database vendor supported by EasyDB, with pointers to its appropriate 
 * {@link QueryGenerator} and {@link DatabaseConnector}. Use to find the right classes for the right 
 * vendor.
 * 
 * @author Mark Tielemans
 * @since 1.0
 * @version 1.0
 */
public class DatabaseVendor {

	public static final DatabaseVendor MYSQL = new DatabaseVendor("mysql", MySQLQueryGenerator.get(), new MySQLConnector());
	
	/**
	 * Register of known, supported database vendors.
	 */
	private static final List<DatabaseVendor> vendors = new ArrayList<DatabaseVendor>();
	static {
		vendors.add(MYSQL);
	}
	
	private String vendorId;
	private QueryGenerator generator;
	private DatabaseConnector connector;
	
	public DatabaseVendor(String vendorId, QueryGenerator generator,
			DatabaseConnector connector) {
		super();
		this.vendorId = vendorId;
		this.generator = generator;
		this.connector = connector;
	}
	
	public String getVendorId() {
		return vendorId;
	}
	
	public QueryGenerator getGenerator() {
		return generator;
	}
	
	public DatabaseConnector getConnector() {
		return connector;
	}
	
	/**
	 * Retrieve a list of known, supported database vendors.
	 * @return list of database vendors
	 */
	public static List<DatabaseVendor> getVendors() {
		return vendors;
	}
}
